# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pymongo
from pymongo import MongoClient


class LactationerSlavePipeline(object):

    def __init__(self):
        # client = MongoClient(host='phonics.brightdot.cn',
        #                      port=35556,
        #                      username="phonics",
        #                      password="PHONICSphonics")

        client = MongoClient(host='127.0.0.1',
                             port=27017)
        # 连接表
        tdb = client.phonics
        self.post = tdb.Lactationer

    def process_item(self, item, spider):
        self.post.insert(dict(item))
        return item
